"""
if分支结构
BMI计算器
"""
height = float(input("请输入身高（cm）"))
weight = float(input("请输出体重（kg）"))
bmi = weight / (height / 100) ** 2
print(f'{bmi=:.1f}')  # f-string功能
if bmi < 18.5:
    print('身体偏瘦')
elif 18.5 <= bmi < 24:
    print('身体均衡')
else:
    print('身体偏肥')

"""
match...case分支结构
"""
status_code = int(input('状态响应码：'))
match status_code:
    case 400 | 402:
        description = 'Bad Request'
    case 401:
        description = 'Unauthorized'
    case 403:
        description = 'Forbidden'
    case 404:
        description = 'Not Found'
    case 405:
        description = 'Method Not Allowed'
    case 500:
        description = 'Internal Server Error'
    case _:
        description = 'Unknown Status Code'
print('状态码描述：', description)

"""
for-in循环
"""
total = 0
for i in range(1, 11):
    print(total := total + i)
print(sum(range(2, 101, 2)))  # 1到100之间的偶数求和

"""
while循环
"""
i = 0
while True:
    i += 1
    if i < 100:
        continue
    else:
        break
print(i)

"""九九乘法表"""
for i in range(1, 10):
    for j in range(1, i + 1):
        print(f'{i} x {j} = {i * j}', end='\t')
    print()


